<template>
  <div class="app-container">
    <el-card class="tableset" shadow="never" :body-style="{ padding: '0px' }">
      <!-- 小标题 -->
      <div class="title">
        <span>云打印机管理</span>
        <el-button
          type="primary"
          class="title-button-right"
          icon="el-icon-plus"
          plain
          @click="openAddCloudPrinterDialog"
        >新增云打印机</el-button>
      </div>
      <!-- 小标题 -->

      <!-- 搜索关键词 -->
      <div class="funtion">
        <el-input
          v-model="get_cloud_printer_info_list.keyword"
          placeholder="请输入关键词"
          class="input-with-select"
          clearable
          @keyup.enter.native="getCloudPrinterInfoList"
        >
          <el-select
            slot="prepend"
            v-model="get_cloud_printer_info_list.keywordType"
            placeholder="请选择"
            class="option"
          >
            <el-option label="产品序列号" value="0" />
            <el-option label="产地" value="1" />
          </el-select>
          <el-button slot="append" icon="el-icon-search" @click="getCloudPrinterInfoList" />
        </el-input>
      </div>
      <!-- 搜索关键词 -->

      <!-- 数据表 -->
      <el-table
        v-loading="dataRequestLoading"
        element-loading-text="正在加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.5)"
        class="table"
        :data="data_cloud_printer_info_list.data"
        highlight-current-row
        stripe
        style="width: 100%;"
        :height="tableHeight"
        :max-height="tableHeight"
        @sort-change="changeSort"
        @filter-change="changefilter"
        @selection-change="getSelection"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column
          label="所在区域"
          :filters="data_cloud_printer_info_list.filter_area"
          :filter-multiple="false"
          column-key="filterAreaId"
        >
          <template slot-scope="{ row }">
            <span>{{ area_id_text(row.area_id) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="打印机品牌及型号"
          :filters="data_cloud_printer_info_list.filter_printer"
          :filter-multiple="false"
          column-key="filterPrinterId"
        >
          <template slot-scope="{ row }">
            <span>{{ printer_id_text(row.printer_id) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="produce_series_number" label="产品序列号" />
        <el-table-column prop="cloud_printer_number" width="200" label="云打印机编号" />
        <el-table-column prop="name" label="云打印机名称" />
        <el-table-column prop="production_place" label="产地" />
        <el-table-column prop="guarantee_time" label="保修期限" />
        <el-table-column label="打印机状态">
          <template slot-scope="{ row }">
            <el-tag :type="status[row.status].color" effect="dark">{{ status[row.status].label }}</el-tag>
            <el-tag :type="row.client_id === '' ? 'danger' : 'success'" effect="dark">{{ row.client_id === '' ? '离线' : '在线' }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="buy_time" label="购买时间" sortable="custom" column-key="buy_time" />
        <el-table-column prop="create_time" label="安装调配时间" sortable="custom" column-key="create_time" />
        <el-table-column fixed="right" label="操作" width="170px">
          <template slot-scope="{ row }">
            <el-button
              type="success"
              @click.stop="
                get_cloud_printer_operating_record.cloud_printer_id = row.cloud_printer_id,
                getCloudPrinterOperatingRecord()
                checkCloudPrinterOperatingRecordDialog = true
              "
            >查看</el-button>
            <el-button
              type="primary"
              @click.stop="openEditCloudPrinterDialog(row)"
            >编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 数据表 -->

      <!-- 数据表左下方功能区 -->
      <div>
        <el-button
          type="success"
          class="card-bottom-button-left"
          icon="el-icon-check"
          plain
          :disabled="startDisabled"
          @click="changeCloudPrinterStatus(1)"
        >启用</el-button>
        <el-button
          type="warning"
          class="card-bottom-button-left"
          icon="el-icon-minus"
          plain
          :disabled="stopDisabled"
          @click="changeCloudPrinterStatus(2)"
        >停用</el-button>
      </div>
      <!-- 数据表左下方功能区 -->

      <!-- 分页 -->
      <el-pagination
        class="pagination"
        background
        layout="total, sizes,prev, pager, next, jumper"
        :total="data_cloud_printer_info_list.total"
        :page-size="get_cloud_printer_info_list.pageSize"
        :page-sizes="[20, 50, 100]"
        :current-page="get_cloud_printer_info_list.currentPage"
        @size-change="changePageSize"
        @current-change="changeCurrentPage"
      />
      <!-- 分页 -->
    </el-card>

    <!-- 异步查询云打印机操作记录 -->
    <el-dialog
      title="查看云打印机操作记录"
      :visible.sync="checkCloudPrinterOperatingRecordDialog"
      width="800px"
      :close-on-click-modal="false"
    >
      <el-input
        v-model="get_cloud_printer_operating_record.keyword"
        style="width:320px;"
        placeholder="请输入关键词"
        @keyup.enter.native="getCloudPrinterOperatingRecord"
      >
        <el-select
          slot="prepend"
          v-model="get_cloud_printer_operating_record.keywordType"
          style="width: 110px;"
          placeholder="请选择"
        >
          <el-option label="操作备注" value="0" />
        </el-select>
        <el-button slot="append" icon="el-icon-search" @click="getCloudPrinterOperatingRecord" />
      </el-input>

      <el-button
        type="danger"
        class="title-button-right"
        style="float: right;margin-left: 0.5rem;"
        icon="el-icon-delete"
        :disabled="deleteDisableDialog"
        plain
        @click="deleteCloudPrinterOperatingRecord"
      >
        删除
      </el-button>
      <el-button
        type="primary"
        class="title-button-right"
        style="float: right;"
        icon="el-icon-plus"
        plain
        @click="openAddCloudPrinterOperatingRecordInnerDialog"
      >
        新增云打印机操作记录
      </el-button>

      <el-table
        v-loading="dialogDataRequestLoading"
        element-loading-text="正在加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.5)"
        class="table"
        :data="data_cloud_printer_operating_record.data"
        highlight-current-row
        :height="tableHeight"
        :max-height="tableHeight"
        stripe
        style="width: 100%;"
        @sort-change="changeSortDialog"
        @filter-change="changefilterDialog"
        @selection-change="getSelectionDialog"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column
          :filters="consumable_type"
          :filter-multiple="false"
          column-key="filterConsumableType"
          prop="consumable_type"
          label="耗材类型"
        >
          <template slot-scope="{ row }">
            <span>{{ consumable_type_text(row.consumable_type) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="specification" label="耗材类型规格" />
        <el-table-column prop="consumable_total" label="耗材量" />
        <el-table-column prop="remark" label="操作备注" />
        <el-table-column prop="create_time" label="操作时间" sortable="custom" column-key="create_time" />
        <el-table-column label="操作">
          <template slot-scope="{ row }">
            <el-button
              type="primary"
              class="normal-button"
              icon="el-icon-edit"
              size="mini"
              @click.stop="openEditCloudPrinterOperatingRecordInnerDialog(row)"
            >编辑</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-pagination
        class="pagination"
        background
        layout="total, sizes,prev, pager, next, jumper"
        :total="data_cloud_printer_operating_record.total"
        :page-size="get_cloud_printer_operating_record.pageSize"
        :page-sizes="[20, 50, 100]"
        :current-page="get_cloud_printer_operating_record.currentPage"
        @size-change="changePageSizeDialog"
        @current-change="changeCurrentPageDialog"
      />
      <!-- 分页 -->

      <!-- 内层新增/修改云打印机操作记录dialog -->
      <el-dialog
        :title="change_cloud_printer_operating_record_title"
        :visible.sync="changeCloudPrinterOperatingRecordInnerDialog"
        width="500px"
        :close-on-click-modal="false"
        append-to-body
      >
        <el-form
          ref="changeCloudPrinterOperatingRecordRulesForm"
          :model="change_cloud_printer_operating_record"
          status-icon
          size="mini"
          label-width="110px"
        >
          <el-form-item prop="consumable_type" :rules="rules.select" label="耗材类型">
            <el-select v-model="change_cloud_printer_operating_record.consumable_type" placeholder="请选择耗材类型">
              <el-option
                v-for="item in consumable_type"
                :key="item.value"
                :label="item.text"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item prop="specification" :rules="rules.input" label="耗材规格">
            <el-input v-model="change_cloud_printer_operating_record.specification" placeholder="请输入耗材规格" clearable />
          </el-form-item>
          <el-form-item prop="consumable_total" :rules="rules.input" label="耗材量">
            <el-input v-model="change_cloud_printer_operating_record.consumable_total" placeholder="请输入耗材量" clearable />
          </el-form-item>
          <el-form-item label="操作备注">
            <el-input v-model="change_cloud_printer_operating_record.remark" type="textarea" placeholder="请输入操作备注" clearable />
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" @click="changeCloudPrinterOperatingRecordInnerDialog = false">取 消</el-button>
          <el-button size="mini" type="primary" @click="changeCloudPrinterOperatingRecord">保 存</el-button>
        </span>
      </el-dialog>
    <!-- 内层新增/修改云打印机操作记录dialog -->
    </el-dialog>
    <!-- 异步查询云打印机操作记录 -->

    <!-- 新增/修改云打印机信息dialog -->
    <el-dialog
      :title="change_cloud_printer_title"
      :visible.sync="changeCloudPrinterDialog"
      width="600px"
      :close-on-click-modal="false"
    >
      <el-form
        ref="changeCloudPrinterRulesForm"
        :model="change_cloud_printer"
        status-icon
        size="mini"
        label-width="110px"
      >
        <el-form-item prop="area_id" :rules="rules.select" label="所在区域">
          <el-select v-model="change_cloud_printer.area_id" placeholder="请选择所在区域">
            <el-option
              v-for="item in data_cloud_printer_info_list.filter_area"
              :key="item.value"
              :label="item.text"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item prop="printer_id" :rules="rules.select" label="打印机品牌及型号">
          <el-select v-model="change_cloud_printer.printer_id" placeholder="请选择打印机品牌及型号">
            <el-option
              v-for="item in data_cloud_printer_info_list.filter_printer"
              :key="item.value"
              :label="item.text"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item prop="produce_series_number" :rules="rules.input" label="云打印机编号">
          <el-input v-model="change_cloud_printer.cloud_printer_number" placeholder="请输入云打印机编号" clearable />
        </el-form-item>
        <el-form-item prop="produce_series_number" :rules="rules.input" label="云打印机名称">
          <el-input v-model="change_cloud_printer.name" placeholder="请输入云打印机名称" clearable />
        </el-form-item>
        <el-form-item prop="produce_series_number" :rules="rules.input" label="产品序列号">
          <el-input v-model="change_cloud_printer.produce_series_number" placeholder="请输入产品序列号" clearable />
        </el-form-item>
        <el-form-item prop="production_place" :rules="rules.input" label="产地">
          <el-input v-model="change_cloud_printer.production_place" placeholder="请输入产地" clearable />
        </el-form-item>
        <el-form-item prop="guarantee_time" :rules="rules.input" label="保修期限">
          <el-input v-model="change_cloud_printer.guarantee_time" placeholder="请输入保修期限" clearable />
        </el-form-item>
        <el-form-item prop="buy_time" :rules="rules.pickTime" label="购买时间">
          <el-date-picker
            v-model="change_cloud_printer.buy_time"
            type="date"
            placeholder="选择购买日期"
          />
        </el-form-item>
        <el-form-item label="打印机状态">
          <el-radio-group v-model="change_cloud_printer.status" size="mini">
            <el-radio-button label="1">启用</el-radio-button>
            <el-radio-button label="0">停用</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="change_cloud_printer.remark" type="textarea" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="changeCloudPrinterDialog = false">取 消</el-button>
        <el-button size="mini" type="primary" @click="changeCloudPrinterInfo">保 存</el-button>
      </span>
    </el-dialog>
    <!-- 新增/修改云打印机信息dialog -->
  </div>
</template>

<script>
import { getDatatime } from '@/common/js/until'
import {
  getCloudPrinterInfoList,
  changeCloudPrinterInfo,
  changeCloudPrinterStatus,
  getCloudPrinterOperatingRecord,
  changeCloudPrinterOperatingRecord,
  deleteCloudPrinterOperatingRecord
} from '@/api/printer'

export default {
  data() {
    return {
      // table高度自适应
      tableHeight: window.innerHeight - 265,

      // loading开关
      dataRequestLoading: false,
      dialogDataRequestLoading: false,

      // 按钮开关
      startDisabled: true,
      stopDisabled: true,
      deleteDisableDialog: true,

      // dialog开关
      changeCloudPrinterDialog: false,
      checkCloudPrinterOperatingRecordDialog: false,
      changeCloudPrinterOperatingRecordInnerDialog: false,

      // 打印机状态显示
      status: {
        0: { color: 'danger', label: '停用' },
        1: { color: 'success', label: '启用' }
      },

      // filter耗材类型
      consumable_type: [
        { value: 0, text: '纸张' },
        { value: 1, text: '墨水' },
        { value: 2, text: '打印头' }
      ],

      // 请求参数
      get_cloud_printer_info_list: {
        pageSize: 20,
        currentPage: 1,
        keyword: '',
        keywordType: '0',
        sort_name: '',
        sort: 'desc',
        filterAreaId: '',
        filterPrinterId: ''
      },

      // 返回值
      data_cloud_printer_info_list: {
        filter_area: [],
        filter_printer: [],
        data: [],
        total: 0
      },

      // 异步查询云打印机操作记录请求参数
      get_cloud_printer_operating_record: {
        cloud_printer_id: '',
        pageSize: 20,
        currentPage: 1,
        keyword: '',
        keywordType: '0',
        sort_name: '',
        sort: 'desc',
        filterConsumableType: ''
      },

      // 异步查询云打印机操作记录返回值
      data_cloud_printer_operating_record: {
        data: [],
        total: 0
      },

      // 编辑云打印机dialog标题
      change_cloud_printer_title: '',

      // 编辑云打印机请求参数
      change_cloud_printer: {
        cloud_printer_id: '',
        area_id: '',
        printer_id: '',
        cloud_printer_number: '',
        name: '',
        produce_series_number: '',
        production_place: '',
        guarantee_time: '',
        buy_time: '',
        status: 1,
        remark: ''
      },

      // 编辑云打印机操作记录dialog标题
      change_cloud_printer_operating_record_title: '',

      // 编辑云打印机请求参数
      change_cloud_printer_operating_record: {
        printer_operating_record_id: '',
        cloud_printer_id: '',
        consumable_type: '',
        specification: '',
        consumable_total: '',
        remark: ''
      },

      // 表单校验规则
      rules: {
        input: { required: true, message: '请完成输入！', trigger: 'blur' },
        select: { required: true, message: '请完成选择！', trigger: 'blur' },
        pickTime: { required: true, message: '请选择日期！', trigger: 'blur' }
      }
    }
  },
  mounted() {
    this.getCloudPrinterInfoList() // 查询云打印机信息列表
  },
  methods: {
    // 查询云打印机信息列表
    getCloudPrinterInfoList() {
      this.dataRequestLoading = true
      getCloudPrinterInfoList(this.get_cloud_printer_info_list).then(res => {
        this.data_cloud_printer_info_list = {
          filter_area: res.result.filter_area,
          filter_printer: res.result.filter_printer,
          data: res.result.showing,
          total: res.result.total
        }
        this.dataRequestLoading = false
      })
    },

    // 所在区域显示
    area_id_text(data) {
      const area_id = this.data_cloud_printer_info_list.filter_area.filter(
        v => {
          if (v.value === data) {
            return v.text
          }
        }
      )
      return area_id[0].text
    },

    // 打印机品牌及型号显示
    printer_id_text(data) {
      const printer_id = this.data_cloud_printer_info_list.filter_printer.filter(
        v => {
          if (v.value === data) {
            return v.text
          }
        }
      )
      return printer_id[0].text
    },

    // 异步查询云打印机操作记录
    getCloudPrinterOperatingRecord() {
      this.dialogDataRequestLoading = true
      getCloudPrinterOperatingRecord(this.get_cloud_printer_operating_record).then(res => {
        this.data_cloud_printer_operating_record = {
          data: res.result.showing,
          total: res.result.total
        }
        this.dialogDataRequestLoading = false
      })
    },

    // 耗材类型显示
    consumable_type_text(data) {
      const consumable_type = this.consumable_type.filter(
        v => {
          if (v.value === data) {
            return v.text
          }
        }
      )
      return consumable_type[0].text
    },

    // 新增/修改云打印机信息
    changeCloudPrinterInfo() {
      this.$refs.changeCloudPrinterRulesForm.validate(valid => {
        if (valid) {
          if (this.change_cloud_printer.buy_time.length === undefined) {
            this.change_cloud_printer.buy_time = getDatatime(this.change_cloud_printer.buy_time)
          }
          changeCloudPrinterInfo(this.change_cloud_printer).then(res => {
            this.getCloudPrinterInfoList()
            this.changeCloudPrinterDialog = false
            this.$notify({
              title: '成功',
              message: '保存云打印机信息成功！',
              type: 'success'
            })
          })
        } else {
          return false
        }
      })
    },

    // 新增/修改云打印机操作记录
    changeCloudPrinterOperatingRecord() {
      this.$refs.changeCloudPrinterOperatingRecordRulesForm.validate(valid => {
        if (valid) {
          changeCloudPrinterOperatingRecord(this.change_cloud_printer_operating_record).then(res => {
            this.getCloudPrinterOperatingRecord()
            this.changeCloudPrinterOperatingRecordInnerDialog = false
            this.$notify({
              title: '成功',
              message: '保存云打印机操作记录成功！',
              type: 'success'
            })
          })
        } else {
          return false
        }
      })
    },

    // 获取选择项
    getSelection(selection) {
      if (selection.length === 0) {
        this.startDisabled = true
        this.stopDisabled = true
      } else {
        this.startDisabled = false
        this.stopDisabled = false
      }
      this.selection = selection
    },

    // 获取操作记录选择项
    getSelectionDialog(selection) {
      if (selection.length === 0) {
        this.deleteDisableDialog = true
      } else {
        this.deleteDisableDialog = false
      }
      this.selectionDialog = selection
    },

    // 批量启动/停用云打印机
    changeCloudPrinterStatus(type) {
      this.$confirm('此操作将改变所选中的云打印机的状态,可改变云打印机是否能运行，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const cloud_printer_id = []
        this.selection.forEach(val => {
          cloud_printer_id.push(val.cloud_printer_id)
        })
        changeCloudPrinterStatus({ type: type, cloud_printer_id: cloud_printer_id }).then(res => {
          this.getCloudPrinterInfoList()
          this.$notify({
            title: '成功',
            message: '修改云打印机状态成功！',
            type: 'success'
          })
        })
      }).catch(() => {
        this.$message({ type: 'info', message: '已取消操作' })
      })
    },

    // 批量删除云打印机操作记录（逻辑删除）
    deleteCloudPrinterOperatingRecord() {
      this.$confirm('此操作将永久删除该云打印机操作记录，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const printer_operating_record_id = []
        this.selectionDialog.forEach(val => {
          printer_operating_record_id.push(val.printer_operating_record_id)
        })
        deleteCloudPrinterOperatingRecord({ printer_operating_record_id: printer_operating_record_id }).then(res => {
          this.getCloudPrinterOperatingRecord()
          this.$notify({
            title: '成功',
            message: '删除云打印机操作记录成功！',
            type: 'success'
          })
        })
      }).catch(() => {
        this.$message({ type: 'info', message: '已取消操作' })
      })
    },

    // 打开新增云打印机信息dialog
    openAddCloudPrinterDialog() {
      this.change_cloud_printer_title = '新增云打印机'
      this.change_cloud_printer = {
        cloud_printer_id: '',
        area_id: '',
        printer_id: '',
        cloud_printer_number: '',
        name: '',
        produce_series_number: '',
        production_place: '',
        guarantee_time: '',
        buy_time: '',
        status: 1,
        remark: ''
      }
      this.changeCloudPrinterDialog = true
    },

    // 打开修改云打印机信息dialog
    openEditCloudPrinterDialog(row) {
      this.change_cloud_printer_title = '修改云打印机'
      this.change_cloud_printer = {
        cloud_printer_id: row.cloud_printer_id,
        area_id: row.area_id,
        printer_id: row.printer_id,
        cloud_printer_number: row.cloud_printer_number,
        name: row.name,
        produce_series_number: row.produce_series_number,
        production_place: row.production_place,
        guarantee_time: row.guarantee_time,
        buy_time: row.buy_time,
        status: row.status,
        remark: row.remark
      }
      this.changeCloudPrinterDialog = true
    },

    // 打开新增云打印机操作记录dialog
    openAddCloudPrinterOperatingRecordInnerDialog() {
      this.change_cloud_printer_operating_record_title = '新增云打印机操作记录'
      this.change_cloud_printer_operating_record = {
        printer_operating_record_id: '',
        cloud_printer_id: this.get_cloud_printer_operating_record.cloud_printer_id,
        consumable_type: '',
        specification: '',
        consumable_total: '',
        remark: ''
      }
      this.changeCloudPrinterOperatingRecordInnerDialog = true
    },

    // 打开修改云打印机操作记录dialog
    openEditCloudPrinterOperatingRecordInnerDialog(row) {
      this.change_cloud_printer_operating_record_title = '修改云打印机操作记录'
      this.change_cloud_printer_operating_record = {
        printer_operating_record_id: row.printer_operating_record_id,
        cloud_printer_id: this.get_cloud_printer_operating_record.cloud_printer_id,
        consumable_type: row.consumable_type,
        specification: row.specification,
        consumable_total: row.consumable_total,
        remark: row.remark
      }
      this.changeCloudPrinterOperatingRecordInnerDialog = true
    },

    // 切换每页条数方法
    changePageSize(data) {
      this.get_cloud_printer_info_list.pageSize = data
      this.getCloudPrinterInfoList()
    },

    // 切换页码方法
    changeCurrentPage(data) {
      this.get_cloud_printer_info_list.currentPage = data
      this.getCloudPrinterInfoList()
    },

    // 操作记录切换每页条数方法
    changePageSizeDialog(data) {
      this.get_cloud_printer_operating_record.pageSize = data
      this.getCloudPrinterOperatingRecord()
    },

    // 操作记录切换页码方法
    changeCurrentPageDialog(data) {
      this.get_cloud_printer_operating_record.currentPage = data
      this.getCloudPrinterOperatingRecord()
    },

    // 更换排序
    changeSort({ column, order }) {
      if (column.columnKey === 'buy_time') {
        switch (order) {
          case 'descending':
            this.get_cloud_printer_info_list.sort_name = 'buy_time'
            this.get_cloud_printer_info_list.sort = 'desc'
            this.getCloudPrinterInfoList()
            break
          case 'ascending':
            this.get_cloud_printer_info_list.sort_name = 'buy_time'
            this.get_cloud_printer_info_list.sort = 'asc'
            this.getCloudPrinterInfoList()
            break
          default:
            this.get_cloud_printer_info_list.sort_name = ''
            this.get_cloud_printer_info_list.sort = 'desc'
            this.getCloudPrinterInfoList()
        }
      } else if (column.columnKey === 'create_time') {
        switch (order) {
          case 'descending':
            this.get_cloud_printer_info_list.sort_name = 'create_time'
            this.get_cloud_printer_info_list.sort = 'desc'
            this.getCloudPrinterInfoList()
            break
          case 'ascending':
            this.get_cloud_printer_info_list.sort_name = 'create_time'
            this.get_cloud_printer_info_list.sort = 'asc'
            this.getCloudPrinterInfoList()
            break
          default:
            this.get_cloud_printer_info_list.sort_name = ''
            this.get_cloud_printer_info_list.sort = 'desc'
            this.getCloudPrinterInfoList()
        }
      }
    },

    // 操作记录更换顺序
    changeSortDialog({ column, order }) {
      if (column.columnKey === 'create_time') {
        switch (order) {
          case 'descending':
            this.get_cloud_printer_operating_record.sort_name = 'create_time'
            this.get_cloud_printer_operating_record.sort = 'desc'
            this.getCloudPrinterOperatingRecord()
            break
          case 'ascending':
            this.get_cloud_printer_operating_record.sort_name = 'create_time'
            this.get_cloud_printer_operating_record.sort = 'asc'
            this.getCloudPrinterOperatingRecord()
            break
          default:
            this.get_cloud_printer_operating_record.sort_name = ''
            this.get_cloud_printer_operating_record.sort = 'desc'
            this.getCloudPrinterOperatingRecord()
        }
      }
    },

    // 筛选记录者
    changefilter(filters) {
      if (filters.filterAreaId) {
        if (filters.filterAreaId.length === 0) {
          this.get_cloud_printer_info_list.filterAreaId = ''
        } else {
          this.get_cloud_printer_info_list.filterAreaId = filters.filterAreaId[0]
        }
      } else if (filters.filterPrinterId) {
        if (filters.filterPrinterId.length === 0) {
          this.get_cloud_printer_info_list.filterPrinterId = ''
        } else {
          this.get_cloud_printer_info_list.filterPrinterId =
            filters.filterPrinterId[0]
        }
      }
      this.getCloudPrinterInfoList()
    },

    // 操作记录筛选记录者
    changefilterDialog(filters) {
      if (filters.filterConsumableType) {
        if (filters.filterConsumableType.length === 0) {
          this.get_cloud_printer_operating_record.filterConsumableType = ''
        } else {
          this.get_cloud_printer_operating_record.filterConsumableType = filters.filterConsumableType[0]
        }
      }
      this.getCloudPrinterOperatingRecord()
    }
  }
}
</script>
